#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct ListNode
{
    int val;
    struct ListNode *next;
    ListNode(int x) : val(x), next(NULL) {}
};

//链表中环的入口结点，三指针，leetcode-142
ListNode *EntryNodeOfLoop(ListNode *pHead)
{
    if (!pHead)
    {
        return NULL;
    }
    ListNode *p1, *p2, *p3;
    p1 = pHead;
    p2 = pHead->next;
    while (p1 != p2)
    {
        if (!p2 || !p2->next)
        {
            return NULL;
        }
        p1 = p1->next;
        p2 = p2->next->next;
    }
    p1 = p1->next;
    p3 = pHead;
    while (p1 != p3)
    {
        p1 = p1->next;
        p3 = p3->next;
    }
    return p1;
}

void test()
{
}

int main()
{
    test();
    return 0;
}